package com.example.demo.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.common.Result;
import com.example.demo.entity.Test1;
import com.example.demo.mapper.TestMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/test")
public class TestController {
    @Resource
    TestMapper testMapper;
    @GetMapping
    public String findPage(@RequestParam(defaultValue = "1") Integer pageNum,
                           @RequestParam(defaultValue = "40") Integer pageSize,
                           @RequestParam(defaultValue = "") String search){
        LambdaQueryWrapper<Test1> wrapper = Wrappers.<Test1>lambdaQuery();
//        if (StrUtil.isNotBlank(search)){
//            wrapper.like(Test::getName, search);
//        }
//        Page<Test1> testPage = testMapper.selectPage(new Page<>(pageNum, pageSize), wrapper);
//        return Result.success(testPage);
        return Result.success(testMapper.getAll1());
    }
}
